﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BeatlesBlog.SimConnect;
using FA.Library.Sim.Aircraft;
using FA.Library.Util;
using System.ComponentModel;

namespace FA.Plugins.FSXPlugin.Sim.Aircraft
{
    [DataStruct()]
    public class FSXAircraftPosition : BaseCloneable, AircraftPosition
    {
        public event PropertyChangedEventHandler PropertyChanged;

        /// <summary>
        /// Latitude.
        /// </summary>
        [DataItem("PLANE LATITUDE", "radians")]
        public double Latitude
        {
            get { return _latitude; }
            set
            {
                if (_latitude != value)
                {
                    _latitude = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("LatitudeDegrees"));
                }
            }
        }
        private double _latitude;

        /// <summary>
        /// Longitude.
        /// </summary>
        [DataItem("PLANE LONGITUDE", "radians")]
        public double Longitude
        {
            get { return _longitude; }
            set
            {
                if (_longitude != value)
                {
                    _longitude = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("LongitudeDegrees"));
                }
            }
        }
        private double _longitude;

        /// <summary>
        /// Altitude in meters.
        /// </summary>
        [DataItem("PLANE ALT ABOVE GROUND", "feet")]
        public float Altitude
        {
            get { return _altitude; }
            set
            {
                if (_altitude != value)
                {
                    _altitude = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("Altitude"));
                }
            }
        }
        private float _altitude;

        /// <summary>
        /// Pitch in radians.
        /// </summary>
        [DataItem("PLANE PITCH DEGREES", "radians")]
        public double Pitch
        {
            get { return _pitchDegrees; }
            set
            {
                if (_pitchDegrees != value)
                {
                    _pitchDegrees = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("PitchDegrees"));
                }
            }
        }
        private double _pitchDegrees;

        /// <summary>
        /// Bank in radians.
        /// </summary>
        [DataItem("PLANE BANK DEGREES", "radians")]
        public double Bank
        {
            get { return _bankDegrees; }
            set
            {
                if (_bankDegrees != value)
                {
                    _bankDegrees = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("BankDegrees"));
                }
            }
        }
        private double _bankDegrees;

        /// <summary>
        /// True heading in radians.
        /// </summary>
        [DataItem("PLANE HEADING DEGREES TRUE", "radians")]
        public double HeadingTrueNorth
        {
            get { return _headingDegreesTrue; }
            set
            {
                if (_headingDegreesTrue != value)
                {
                    _headingDegreesTrue = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("HeadingDegreesTrueNorth"));
                }
            }
        }
        private double _headingDegreesTrue;

        /// <summary>
        /// Magnetic heading in radians.
        /// </summary>
        [DataItem("PLANE HEADING DEGREES MAGNETIC", "radians")]
        public double HeadingMagnetic
        {
            get { return _headingDegreesMagnetic; }
            set
            {
                if (_headingDegreesMagnetic != value)
                {
                    _headingDegreesMagnetic = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("HeadingDegreesMagnetic"));
                }
            }
        }
        private double _headingDegreesMagnetic;
    }
}